home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
ansitc
/
ansi.c
next >
Wrap
Text File
|
1987-08-20
|
4KB
|
116 lines
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* ANSI Generator Function - This function will return the ANSI */
/* color codes for the foreground and background colors passed as */
/* paramaters. The forground and background colors are in the */
/* range of: */
/* FOREGROUND BACKGROUND */
/* 0 = black 0 = black */
/* 1 = blue 1 = blue */
/* 2 = green 2 = green */
/* 3 = cyan 3 = cyan */
/* 4 = red 4 = red */
/* 5 = magenta 5 = magenta */
/* 6 = brown 6 = brown */
/* 7 = grey 7 = grey */
/* 8 = light grey */
/* 9 = light blue */
/* 10 = light green */
/* 11 = light cyan */
/* 12 = light red */
/* 13 = light magenta */
/* 14 = yellow */
/* 15 = white */
/* 16 = blink on */
/* 17 = blink off */
void SET_COLOR(int foreground,int background, char string[])
{
switch(background)
{
case 0:
strcpy(string,"\x1b[40m");
break;
case 1:
strcpy(string,"\x1b[44m");
break;
case 2:
strcpy(string,"\x1b[42m");
break;
case 3:
strcpy(string,"\x1b[46m");
break;
case 4:
strcpy(string,"\x1b[41m");
break;
case 5:
strcpy(string,"\x1b[45m");
break;
case 6:
strcpy(string,"\x1b[43m");
break;
case 7:
strcpy(string,"\x1b[47m");
break;
default:break;
}
switch(foreground)
{
case 0:
strcat(string,"\x1b[30m");
break;
case 1:
strcat(string,"\x1b[34m");
break;
case 2:
strcat(string,"\x1b[32m");
break;
case 3:
strcat(string,"\x1b[36m");
break;
case 4:
strcat(string,"\x1b[31m");
break;
case 5:
strcat(string,"\x1b[35m");
break;
case 6:
strcat(string,"\x1b[33m");
break;
case 7:
strcat(string,"\x1b[37m");
break;
case 8:
strcat(string,"\x1b[1;30m");
break;
case 9:
strcat(string,"\x1b[1;34m");
break;
case 10:
strcat(string,"\x1b[1;32m");
break;
case 11:
strcat(string,"\x1b[1;36m");
break;
case 12:
strcat(string,"\x1b[1;31m");
break;
case 13:
strcat(string,"\x1b[1;35m");
break;
case 14:
strcat(string,"\x1b[1;33m");
break;
case 15:
strcat(string,"\x1b[1;37m");
break;
case 16:
strcat(string,"\x1b[5");
break;
case 17:
strcat(string,"\x1b[0");
break;
default:break;
}
}